I had my first legit pairing yesterday. It is definitely something to get used to... I was a bit flusterred to say the least. And I totally made an outline to write about my whole experience, but this isn't about that, but about something mentioned during... it's called AAA.
What is AAA? At first, I thought of the band... then the auto club for towing... spoiler alert, it is neither. So then what does it stand for? AAA is shorthand for Arrange-Action-Assertion
and it is a pattern for formatting code within testing methods. Keeping AAA in mind should make misuse of a test apparent, such as testing multiple things at once. Perhaps, not simplifyng it enough-- laser focused.
With that said, during the pairing I realized I am guilty of not breaking things down to its most basic. In other words, I'm already thinking maybe 1 or 2 steps ahead when trying to solve a problem. In testing, however, doing that could potentially muck up the test since you should be testing for something specific.
When following AAA:
Each method is seperated by a blank line clearly depicting which part of AAA you are in--
Arrange
necessary preconditions and inputs, ie: arranging things before calling method/ function
Action
on object/method under test
Assertion
that expectations are met, ie: output returns expected results
Upon hearing about AAA I thought it to be an excellent way to check yourself-- if your tests ever deviate from the simple lane, this template/ guideline should, in a sense, "break" indicating a problem.